package com_djm_2025_05_11;

/**
 * @author dengjiangming
 * @version 1.0.0
 * @date 2025-05-15
 */
public class Demo10 {

    public static long fiboni(int n){
        if(n == 1 || n == 2){
            return 1;
        }

        long f1 = 1;
        long f2 = 1;
        long f3 = 0;

        for(int i = 3;i <= n;i++){
            f3 = f1+f2;
            f1 = f2;
            f2 = f3;
        }

        return f3;
    }

    public static void main(String[] args) {

        //求斐波那契序列的第n项
        long num = fiboni(7);
        System.out.println(num);
    }
}
